package com.atguigu.java8.day21.java;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Locale;

/**
 * @author
 * @creator 夏焰波
 * @date 2019-11-14 5:22
 */
public class DateTimeFormattertest {

    public static void main(String[] args) {
        //使用本地化的风格来创建格式
        DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.MEDIUM);
        LocalDateTime date = LocalDateTime.now();

        System.out.println(date.format(formatter));
        System.out.println(formatter.format(date));

//        ZonedDateTime zonedDateTime= ZonedDateTime.now();
        ZonedDateTime zonedDateTime= ZonedDateTime.now(ZoneId.of("Asia/Shanghai"));
        String str2 = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG).withLocale(Locale.CHINA).format(zonedDateTime);
        System.out.println(str2);

    }
}